<meta charset="utf-8"/>
<link rel="stylesheet" href="css/welcome.css"/>
<style>
  .page-content{
    background-color:#F5F6FA;
  }
</style>
<div class="row main-bg">
  <!--页面主要内容-->
  <div permission='welcome_btn_getDataOverview' style="padding:10px;display: none;">
    <div class="row">
      <div class="col-sm-6 col-lg-3">
        <div class="card" style="background-color:#33CABB;">
          <div class="card-body clearfix">
            <div class="pull-right">
              <p class="h6 card-content-title">待兑换积分</p>
              <p class="h3 card-content-value" id="totalMoney"></p>
            </div>
            <div class="pull-left"> 
              <span class="img-avatar img-avatar-48 bg-translucent">
                <i class="ace-icon fa fa-rmb"></i>
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="col-sm-6 col-lg-3">
        <div class="card" style="background-color:#926DDE;">
          <div class="card-body clearfix">
            <div class="pull-right">
              <p class="h6 card-content-title">待发货订单</p>
              <p class="h3 card-content-value" id="totalWait"></p>
            </div>
            <div class="pull-left"> 
              <span class="img-avatar img-avatar-48 bg-translucent">
                <i class="ace-icon fa fa-truck"></i>
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="col-sm-6 col-lg-3">
        <div class="card" style="background-color:#F96868;">
          <div class="card-body clearfix">
            <div class="pull-right">
              <p class="h6 card-content-title">用户总数</p>
              <p class="h3 card-content-value" id="totalUser"></p>
            </div>
            <div class="pull-left"> 
              <span class="img-avatar img-avatar-48 bg-translucent">
                <i class="ace-icon glyphicon glyphicon-user"></i>
              </span>
            </div>
          </div>
        </div>
      </div>
      <div class="col-sm-6 col-lg-3">
        <div class="card" style="background-color:#15C377;">
          <div class="card-body clearfix">
            <div class="pull-right">
              <p class="h6 card-content-title">积分商城支付订单数</p>
              <p class="h3 card-content-value" id="totalOrder"></p>
            </div>
            <div class="pull-left"> 
              <span class="img-avatar img-avatar-48 bg-translucent">
                <i class="ace-icon fa fa-cart-arrow-down"></i>
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div id="partnerView" style="padding:10px;display: none;">
    <div style="font-size:16px;margin:10px 4px 10px 4px;">我在贵州等你酒运营管理平台</div>
  </div>
  <!--End 页面主要内容-->
</div>
<script type="text/javascript">
  var items = JSON.parse(sessionStorage.getItem("btnRows"));
  $.each(items,function(index,item){
    var value = item.permission;
    $("[permission='"+value+"']").css({"display":""});//若存在权限标识则把 display 置空即可
  });
  $(function($){
    var urlRoute = '/welcome/';
    var getAllUser = urlRoute + 'getAllUser';
    var urlGetDataOverview = urlRoute + 'getDataOverview';/*首页数据概览统计数据 销售总金额 用户总数量 销售订单数量 待配送的订单数量*/
    thisPage = {
      init : function(){
        this.initDom();
        this.btnEvent();
      },
      initDom : function(){
        authHandler('welcome_btn_getAllUser', function(){
          layerFn.queryGetHintResult(getAllUser,{},function(data){

          });
        },function(){
          $('#viewRoot').css({"display":"none"});
        });
        authHandler('welcome_btn_getDataOverview', function(){
          thisPage.getDataOverview();
        },function(){
          $('#partnerView').css({"display":""});
        });
      },
      btnEvent : function(){},
      getDataOverview : function(){
        layerFn.ajaxGetResult(urlGetDataOverview,{},function(data){
          if(AppKey.code.code200 == data.code){
            var value = data.data;
            $("#totalMoney").html(value.totalExchange ? value.totalExchange : value.totalExchange == 0 ? 0 : '');
            $("#totalWait").html(value.totalWait ? value.totalWait : value.totalWait == 0 ? 0 : '');
            $("#totalOrder").html(value.totalOrder ? value.totalOrder : value.totalOrder == 0 ? 0 : '');
            $("#totalUser").html(value.totalUser || '');
          }else if(AppKey.code.code201 == data.code){

          }else{
            $("#totalMoney").html(data.msg);
            $("#totalUser").html(data.msg);
            $("#totalOrder").html(data.msg);
            $("#totalWait").html(data.msg);
          }
        });
      },
    }
    thisPage.init();
    $('script').remove();
  });
</script>